import commonService from 'service/common'
export default {
    // 公告列表
    async list(data, userKey, search_data, readStatus) {
        if (!search_data) {
            search_data = ["0", "1", "2"]
        }
        if (!readStatus) {
            readStatus = "2";
        }
        let dataObj = {
            "group": {
                "filters": [{
                    "queryOperator": "IN",
                    "searchName": "status",
                    "value": search_data
                }],
                "groups": [
                    {}
                ],
                "operator": "AND"
            },
            "page": {
                "pageNumber": data.pageNumber,
                "pageSize": data.pageSize,
                "sort": [{
                    "direction": "ASC",
                    "property": "id"
                }]
            }
        };
        let paramsJson = {
            baseURL: '/8third',
            method: 'post',
            url: 'common/notices/search/' + userKey + "/" + readStatus,
            data: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    // 添加公告
    async add(data) {
        let dataObj = Object.assign({
            title: '',
            desp: '',
            startTime: '',
            endTime: '',
            noticeType: '',
            status: '',
            readers: []
        }, data)
        let paramsJson = {
            baseURL: '/8third',
            method: 'post',
            url: 'common/notices',
            data: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //删除
    async delete(id) {
        let paramsJson = {
            baseURL: '/8third',
            method: 'delete',
            url: 'common/notices/' + id
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //修改状态
    async changeStatus(id, status) {
        let paramsJson = {
            baseURL: '/8third',
            method: 'put',
            url: 'common/notices/' + id + "/" + status
        };
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //跑马灯
    async getMarquee(data) {
        let dataObj = Object.assign({
            userKey: ''
        }, data)
        let paramsJson = {
            baseURL: '/8third',
            method: 'post',
            url: 'common/notices/horseRaceLamp/' + dataObj.userKey
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    // 查询组织架构
    async getOrganizationList(data) {
        let dataObj = Object.assign({

        }, data)

        let paramsJson = {
            baseURL: '/webapiThird',
            method: 'get',
            url: 'webapi/organization/list',
            params: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    // 根据id查询架构下的人
    async getOrganizationPerson(data) {
        let dataObj = Object.assign({
            orgIdList: ""
        }, data)
        let paramsJson = {
            baseURL: '/webapiThird',
            method: 'get',
            url: 'webapi/user/listByOrgId',
            params: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    // 查看公告详情
    async getAnnounceInfo(id, userKey) {
        let paramsJson = {
            baseURL: '/8third',
            method: 'get',
            url: 'common/notices/' + id + "/" + userKey
        };
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    }
}